package com.website.common.vo;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 树
 *
 * @author zhangshuw
 * @date 2017/7/9
 */
public class Tree implements Serializable {

	private static final long serialVersionUID = 1L;

	protected Integer id;
	private Integer parentId;
	protected String text;
	/**
	 * true则在text前有个选中的复选框,false则text前有个未选中的复选框,默认没有任何框框
	 */
	protected Boolean checked;
	/**
	 * 展开,默认不展开
	 */
	protected Boolean expanded;
	/**
	 * 节点的链接地址
	 */
	protected String href_;
	/**
	 * 打开节点链接地址默认为blank,可以设置为iframe名称id,则在iframe中打开
	 */
	protected String hrefTarget;
	/**
	 * 叶子节点,看情况设置
	 */
	protected Boolean leaf;
	/**
	 * 提示信息,不过要 Ext.QuickTips.init();下
	 */
	protected String qtip;
	/**
	 * 用单击文本展开,默认为双击
	 */
	protected Boolean singleClickExpand;
	protected String icon;
	protected Integer sort;

	private Map<String, Object> attributes = new HashMap<>();

	private List<Tree> children = new ArrayList<>();


	public Tree() {
		this(null, null);
	}

	public Tree(Integer id, String text) {
		this(id, text, null);
	}

	public Tree(Integer id, String text, String href) {
		this(id, text, false, href);
	}

	/**
	 *
	 * @param id
	 *            节点id
	 * @param text
	 *            树节点名称
	 * @param expanded
	 *            是否展开
	 * @param href
	 *            链接
	 */
	public Tree(Integer id, String text, boolean expanded, String href) {
		this.id = id;
		this.text = text;
		this.expanded = expanded;
		this.href_ = href;
	}

	public Tree(Integer id, String text, String href, Boolean checked,
			Boolean expanded) {
		super();
		this.id = id;
		this.text = text;
		this.icon = href;
		this.checked = checked;
		this.expanded = expanded;
	}

	public Tree addChild(Tree childNode) {
		this.children.add(childNode);
        return this;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Integer getParentId() {
		return parentId;
	}

	public void setParentId(Integer parentId) {
		this.parentId = parentId;
	}

	public Boolean getChecked() {
		return checked;
	}

	public Boolean getExpanded() {
		return expanded;
	}

	public Boolean getLeaf() {
		return leaf;
	}

	public Boolean getSingleClickExpand() {
		return singleClickExpand;
	}

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	public Boolean isChecked() {
		return checked;
	}

	public void setChecked(Boolean checked) {
		this.checked = checked;
	}

	public Boolean isExpanded() {
		return expanded;
	}

	public void setExpanded(Boolean expanded) {
		this.expanded = expanded;
	}

	public String getHref_() {
		return href_;
	}

	public void setHref_(String href) {
		this.href_ = href;
	}

	public String getHrefTarget() {
		return hrefTarget;
	}

	public void setHrefTarget(String hrefTarget) {
		this.hrefTarget = hrefTarget;
	}

	public Boolean isLeaf() {
		return leaf;
	}

	public void setLeaf(Boolean leaf) {
		this.leaf = leaf;
	}

	public String getQtip() {
		return qtip;
	}

	public void setQtip(String qtip) {
		this.qtip = qtip;
	}

	public Boolean isSingleClickExpand() {
		return singleClickExpand;
	}

	public void setSingleClickExpand(Boolean singleClickExpand) {
		this.singleClickExpand = singleClickExpand;
	}

	public String getIcon() {
		return icon;
	}

	public void setIcon(String icon) {
		this.icon = icon;
	}

	public Integer getSort() {
		return sort;
	}

	public void setSort(Integer sort) {
		this.sort = sort;
	}

	public Map<String, Object> getAttributes() {
		return attributes;
	}

	public void setAttributes(Map<String, Object> attributes) {
		this.attributes = attributes;
	}

	public List<Tree> getChildren() {
		return children;
	}

	public void setChildren(List<Tree> children) {
		this.children = children;
	}
}
